package com.adcc.ags.gms.core.service;

import com.adcc.ags.gms.core.entity.SysUser;
import com.adcc.ags.gms.core.mapper.SysUserMapper;
import com.adcc.ags.gms.core.util.LogFactory;
import com.google.common.base.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 用户实现层
 */
@Service("SysUserService")
public class SysUserServiceImpl implements SysUserService {
    @Autowired
    private SysUserMapper sysUserMapper;

    @Autowired
    private LogFactory log;

    @Override
    public Optional<SysUser> findByCondition(String name, String password, int type) {
        try {
            SysUser sysUser = sysUserMapper.findByCondition(name, password, type);
            if (sysUser != null) {
                return Optional.of(sysUser);
            } else {
                return Optional.absent();
            }
        } catch (Exception e) {
            log.error(SysUserService.class, "findByCondition() error", e);
            return Optional.absent();
        }

    }
}
